var yazl = require("yazl");

var zipfile = new yazl.ZipFile();
var pt = require('path');
var glob = require('glob');
var fs = require('fs');
var files = glob.sync(pt.join(__dirname, 'node_modules/as-stream') + '/**', {nodir: true});
console.log(files);
files.forEach(function(file) {
  var rp = pt.relative(__dirname, file);
  console.log(rp);
  zipfile.addFile(file, rp);
});
// pipe() can be called any time after the constructor
zipfile.outputStream.pipe(fs.createWriteStream("output.zip")).on("close", function(err) {
  if (err) console.log(err);
  console.log("done");
});
/*
// alternate apis for adding files:
zipfile.addReadStream(process.stdin, "stdin.txt", {
  mtime: new Date(),
  mode: 0100664, // -rw-rw-r--
});
zipfile.addBuffer(new Buffer("hello"), "hello.txt", {
  mtime: new Date(),
  mode: 0100664, // -rw-rw-r--
});
// call end() after all the files have been added
zipfile.end();
*/
zipfile.end();
